﻿<!doctype html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <title>Hui</title>
    <link rel="stylesheet" type="text/css" href="../css/app.css" />
    <link rel="stylesheet" type="text/css" href="../css/iconfont.css" />
    
    <script type="text/javascript" src="../script/api.js"></script>
    <script type="text/javascript" src="../script/jquery-1.12.0.min.js"></script>
	<script type="text/javascript" src="../script/app.js" ></script>
    <style type="text/css">
		body{height:100%;}
    	/*.hui { background: #f4f5f9}*/
    	.W-active{
    		border:1px solid #ddb240;
    	}
    </style>
</head>
<body class="">

    <div class=" H-horizontal-left H-max-width-100-percent H-padding-horizontal-both-10 H-text-show-row-1">
        <div class="H-theme-font-color-999  H-flexbox-horizontal  H-box-sizing-border-box">
				<div class="H-text-align-center " style="margin:20px auto;">
                    <label class="H-display-block  H-margin-vertical-top-5 H-theme-font-color-333">
                    	<a class="user_level H-font-size-16">当前服务：普通会员</a><br/>
                    	<a style="display: block;" class="user_level_time H-font-size-14" id="vip_end_time">到期时间：2000-1-1</a>
                    </label>
                </div>
            </div>
    </div>
    
  
    
    <div class="H-flexbox-horizontal  H-padding-horizontal-both-10">
        <input type="text" id="card_no" class="H-textbox H-vertical-align-middle H-vertical-middle H-font-size-16 H-flex-item H-box-sizing-border-box H-border-none H-outline-none H-padding-12" placeholder="输入充值卡的卡号...">
    </div>
    
    <div onclick="subtn();" class="H-padding-15 H-margin-vertical-top-10">
        <button class="H-button H-width-100-percent  H-font-size-15 H-outline-none H-padding-vertical-both-15 H-padding-horizontal-both-20 H-theme-background-color-497bf0 H-theme-font-color-white H-border-radius-3">兑 换</button>
    </div>
    
 



	<script>
	
		token = localStorage.getItem('token');
		var id = "";
		var cert_flag = "";
		var user_level_status = "";
		var cert = "";
		apiready = function(){
			            
			api.addEventListener({
	            name:'push_user_info'
            },function(ret,err){
            	token = localStorage.getItem('token');
            	if(token !='' && token!=null  && typeof token !='undefined'){
					userInfo = $api.getStorage('userinfo');
					
					if( userInfo.vip == 1){
						$(".user_level").text('当前服务：体验会员');
					} else if( userInfo.vip == 2){
						$(".is_vip").show();
						$(".user_level").text('当前服务：钻石会员');
						
					} else {
						$("#user_level").text( "当前服务：未开通会员" );
					}
					
					$("#vip_end_time").text(   _formatDate(userInfo.vip_end_time *1000) + " 到期"  );
				}
            });
			if(token !='' && token!=null  && typeof token !='undefined'){
				userInfo = $api.getStorage('userinfo');
				
				if( userInfo.vip == 1){
				
					$(".user_level").text('当前服务：体验会员');
				} else if( userInfo.vip == 2){
					$(".is_vip").show();
					$(".user_level").text('当前服务：钻石会员');
					
				} else {
					$("#user_level").text( "当前服务：未开通会员" );
				}
				
				$("#vip_end_time").text(   _formatDate(userInfo.vip_end_time *1000) + " 到期"  );
			}
		}
		
		

	    
	  
	    
	    //充值
	    function subtn(){
	    	var card_no = $("#card_no").val();
	    	token = localStorage.getItem('token');
	    	if(token !='' && token!=null  && token!='undefined'){
	    		$app.ajax($app.serverUrl+"index/user/subCardNo",{
	    			'card_no' :card_no,
	    			'token' :token
	    		},'post',function(ret){
	    			if( ret.status == 1000){
	    				
						api.sendEvent({
		                    name:'get_user_info'
	                    });
	                    $("#card_no").val('');
	                    $app.toast( '兑换成功' );
	    			} else {
	    				$app.toast( ret.msg );
	    			}
	    		});
	    		
	    	} else {
	    		login();
	    	}
	    	
	    }
	    
	    function _openWinHead(name,url,title){
			token = localStorage.getItem('token');
			if(token !='' && token!=null  && token!='undefined'){
				
				$app.openWinByUrl(name+'win_head','./win_head',{'fname':name,'furl':url,'title':title});
			}else{
				login();
			}
		}
		function login(){
			$app.openWinByUrl('login','login')
		}
		
		
	

	</script>
</body>
</html>